/**
 * Copyright 2011 Aaron Zeckoski
 * This file is part of Maven Exercise 6.
 *
 * Maven Exercise 6 is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Maven Exercise 6 is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Maven Exercise 6.  If not, see <http://www.gnu.org/licenses/>.
 */
package org.az.dao.impl;

import org.az.dao.CommentsDAO;
import org.az.dao.entity.CommentsEntity;
import org.az.dao.impl.GenericHibernateDAOImpl;
import org.hibernate.Criteria;
import org.hibernate.criterion.Projections;
import org.springframework.stereotype.Repository;

/**
 * Plain DAO which provides only {@link org.az.server.dao.impl.GenericHibernateDAOImpl} methods
 */
@Repository
public class CommentsDAOImpl extends GenericHibernateDAOImpl<CommentsEntity, Long> implements CommentsDAO {

    public int countAll() {
        Criteria criteria = getSession().createCriteria(persistentClass);
        criteria.setProjection(Projections.rowCount());
        Long count = (Long) criteria.uniqueResult();
        return count.intValue();
    }

}
